package com.hsnn.medstgmini.pro.base.dao.Impl;

import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hsnn.medstgmini.dao.HibernateSqlUtil;
import com.hsnn.medstgmini.pro.base.dao.AnaDruginfoCSDao;
import com.hsnn.medstgmini.util.AreaUtil;
import com.hsnn.medstgmini.util.Pagination;
import com.hsnn.medstgmini.util.ParseDate;
import com.hsnn.medstgmini.util.DateUtil;

@Service
public class AnaDruginfoCSDaoImpl implements AnaDruginfoCSDao {
	@Autowired
	private HibernateSqlUtil dao;
	
	/**
	 * 
	 *@category 按药品汇总统计（每日）
	 *@author lil
	 *@date 2015年12月4日 
	 *@param 
	 *@return Pagination
	 */
	@Override
	public Pagination getAnaByDrugs(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ad.*,bgi.qualityspec_name drug_name,bgi.form_name,bgi.spec_name, ")
		.append(" bgi.factor,bgi.unit_name,bgi.material_name,bgi.prod_compname,bgi.prod_compcode ")
		.append(" from ana_druginfo ad left join base_goods_item bgi on bgi.drug_code =ad.drug_code where 1=1  ");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and ad.is_basic=:isBasic ");
		}
		sql.append(" ORDER BY ad.date desc ");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}

	@Override
	public Pagination getAnaByHosp(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.hosp_code,ah.hosp_name,ah.date, ")
		.append(" ah.hosp_classify,ah.total_amount,ah.base_amount,ah.nonbase_amount,ah.ret_amount, ")
		.append(" ah.base_ratio, ")
		.append(" ah.ret_ratio ")
		.append("  from ana_hospital ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("hospName"))) {
			sql.append(" and (ah.hosp_name like :hospName or ah.hosp_spel_code like :hospName )");
			map.put("hospName", "%"+map.get("hospName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startDate"))) {
			map.put("startDate", map.get("startDate").replaceAll("-", ""));
			sql.append(" and ah.date >= :startDate ");
		}
		if (StringUtils.isNotBlank(map.get("endDate"))) {
			map.put("endDate", map.get("endDate").replaceAll("-", ""));
			sql.append(" and ah.date <= :endDate ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), map, page);
	}

	@Override
	public Pagination getAnaByArea(Pagination page) {
		StringBuffer sql = new StringBuffer()
		.append("select t.area_id,t.area_name,t.total_amount,t.base_amount,t.nonbase_amount,")
		.append("t.base_ratio,t.del_amount,t.del_ration,t.ret_amount,t.ret_ratio,t.date ")
		.append(" from ana_area t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startDay"))){
			sql.append(" and t.date >= :startDay");
			params.put("startDay", map.get("startDay"));
		}
		if (StringUtils.isNotBlank(map.get("endDay"))){
			sql.append(" and t.date <= :endDay");
			params.put("endDay", map.get("endDay"));
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	@Override
	public Pagination getAnaCompinfoByArea(Pagination page) {
		StringBuffer sql = new StringBuffer()
		.append("select t.area_id,t.area_name,t.del_comp_code,t.del_comp_name,t.total_amount,t.base_amount,t.nonbase_amount,")
		.append("t.base_ratio,t.del_amount,t.del_ratio,t.ret_amount,t.ret_ratio,t.date ")
		.append(" from ana_compinfo_area t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startDay"))){
			sql.append(" and t.date >= :startDay");
			params.put("startDay", map.get("startDay"));
		}
		if (StringUtils.isNotBlank(map.get("endDay"))){
			sql.append(" and t.date <= :endDay");
			params.put("endDay", map.get("endDay"));
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	/**
	 * 
	 *@category 获取药品采购统计,跳向按地区查询数据
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	public Pagination getAnaByAreaWithYear(Pagination page){
		StringBuffer sql = new StringBuffer()
		.append("select t.area_id,t.area_name,t.total_amount,t.base_amount,t.nonbase_amount,")
		.append("t.base_ratio,t.del_amount,t.del_ration,t.ret_amount,t.ret_ratio,t.date ")
		.append(" from ana_area_year t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startYear"))){
			sql.append(" and t.date >= :startYear");
			params.put("startYear", map.get("startYear"));
		}
		if (StringUtils.isNotBlank(map.get("endYear"))){
			sql.append(" and t.date <= :endYear");
			params.put("endYear", map.get("endYear"));
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	public Pagination getAnaCompinfoByAreaWithYear(Pagination page){
		StringBuffer sql = new StringBuffer()
		.append("select t.area_id,t.area_name,t.del_comp_code,t.del_comp_name,t.total_amount,t.base_amount,t.nonbase_amount,")
		.append("t.base_ratio,t.del_amount,t.del_ratio,t.ret_amount,t.ret_ratio,t.date ")
		.append(" from ana_compinfo_area_year t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startYear"))){
			sql.append(" and t.date >= :startYear");
			params.put("startYear", map.get("startYear"));
		}
		if (StringUtils.isNotBlank(map.get("endYear"))){
			sql.append(" and t.date <= :endYear");
			params.put("endYear", map.get("endYear"));
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	
	public Pagination getAnaByAreaWithSea(Pagination page){
		StringBuffer sql = new StringBuffer()
		.append("select t.area_id,t.area_name,t.total_amount,t.base_amount,t.nonbase_amount,")
		.append("t.base_ratio,t.del_amount,t.del_ration,t.ret_amount,t.ret_ratio,t.date ")
		.append(" from ana_area_sea t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startSea"))){
			sql.append(" and t.date >= :startSea");
			params.put("startSea", map.get("startSea"));
		}
		if (StringUtils.isNotBlank(map.get("endSea"))){
			sql.append(" and t.date <= :endSea");
			params.put("endSea", map.get("endSea"));
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	public Pagination getAnaCompinfoByAreaWithSea(Pagination page){
		StringBuffer sql = new StringBuffer()
		.append("select t.area_id,t.area_name,t.del_comp_code,t.del_comp_name,t.total_amount,t.base_amount,t.nonbase_amount,")
		.append("t.base_ratio,t.del_amount,t.del_ratio,t.ret_amount,t.ret_ratio,t.date ")
		.append(" from ana_compinfo_area_sea t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startSea"))){
			sql.append(" and t.date >= :startSea");
			params.put("startSea", map.get("startSea"));
		}
		if (StringUtils.isNotBlank(map.get("endSea"))){
			sql.append(" and t.date <= :endSea");
			params.put("endSea", map.get("endSea"));
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	
	
	public Pagination getAnaByAreaWithMon(Pagination page){
		StringBuffer sql = new StringBuffer()
		.append("select t.area_id,t.area_name,t.total_amount,t.base_amount,t.nonbase_amount,")
		.append("t.base_ratio,t.del_amount,t.del_ration,t.ret_amount,t.ret_ratio,t.date ")
		.append(" from ana_area_mon t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startMon"))){
			sql.append(" and t.date >= :startMon");
			params.put("startMon", map.get("startMon"));
		}
		if (StringUtils.isNotBlank(map.get("endMon"))){
			sql.append(" and t.date <= :endMon");
			params.put("endMon", map.get("endMon"));
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	
	public Pagination getAnaCompinfoByAreaWithMon(Pagination page){
		StringBuffer sql = new StringBuffer()
		.append("select t.area_id,t.area_name,t.total_amount,t.base_amount,t.nonbase_amount,")
		.append("t.base_ratio,t.del_amount,t.del_ration,t.ret_amount,t.ret_ratio,t.date ")
		.append(" from ana_compinfo_area_mon t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startMon"))){
			sql.append(" and t.date >= :startMon");
			params.put("startMon", map.get("startMon"));
		}
		if (StringUtils.isNotBlank(map.get("endMon"))){
			sql.append(" and t.date <= :endMon");
			params.put("endMon", map.get("endMon"));
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	/**
	 * @category 按医院统计(年)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getYearAnaByHosp(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.hosp_code,ah.hosp_name,ah.date, ")
		.append(" ah.hosp_classify,ah.total_amount,ah.base_amount,ah.nonbase_amount,ah.ret_amount, ")
		.append(" ah.base_ratio, ")
		.append(" ah.ret_ratio ")
		.append("  from ana_hospital_year ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("hospName"))) {
			sql.append(" and (ah.hosp_name like :hospName or ah.hosp_spel_code like :hospName )");
			map.put("hospName", "%"+map.get("hospName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startYear"))) {
			sql.append(" and ah.date >= :startYear ");
		}
		if (StringUtils.isNotBlank(map.get("endYear"))) {
			sql.append(" and ah.date <= :endYear ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), map, page);
	}
	
	
	/**
	 * @category 按医院统计(季度)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getSeaAnaByHosp(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.hosp_code,ah.hosp_name,ah.date, ")
		.append(" ah.hosp_classify,ah.total_amount,ah.base_amount,ah.nonbase_amount,ah.ret_amount, ")
		.append(" ah.base_ratio, ")
		.append(" ah.ret_ratio ")
		.append("  from ana_hospital_sea ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("hospName"))) {
			sql.append(" and (ah.hosp_name like :hospName or ah.hosp_spel_code like :hospName )");
			map.put("hospName", "%"+map.get("hospName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startSea"))) {
			map.put("startSea", map.get("startSea").replaceAll("年第", "0").replaceAll("季度", ""));
			sql.append(" and ah.date >= :startSea ");
		}
		if (StringUtils.isNotBlank(map.get("endSea"))) {
			map.put("endSea", map.get("endSea").replaceAll("年第", "0").replaceAll("季度", ""));
			sql.append(" and ah.date <= :endSea ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 按医院统计(月)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getMonthAnaByHosp(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.hosp_code,ah.hosp_name,ah.date, ")
		.append(" ah.hosp_classify,ah.total_amount,ah.base_amount,ah.nonbase_amount,ah.ret_amount, ")
		.append(" ah.base_ratio, ")
		.append(" ah.ret_ratio ")
		.append("  from ana_hospital_mon ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("hospName"))) {
			sql.append(" and (ah.hosp_name like :hospName or ah.hosp_spel_code like :hospName )");
			map.put("hospName", "%"+map.get("hospName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startMonth"))) {
			map.put("startMonth", map.get("startMonth").replaceAll("-", ""));
			sql.append(" and ah.date >= :startMonth ");
		}
		if (StringUtils.isNotBlank(map.get("endMonth"))) {
			map.put("endMonth", map.get("endMonth").replaceAll("-", ""));
			sql.append(" and ah.date <= :endMonth ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), map, page);
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaTotalByTime() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select adt.ana_id,adt.is_basic,adt.total_a"
				+ "mount,adt.del_amount,adt.ret_amount,")
		.append("adt.date from ana_druginfo_total adt where :date <= adt.date")
		.append(" ORDER BY adt.date");
		
		map.put("date", ParseDate.parseDateToYmd(ParseDate.addDate(new Date(), -7)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品采购月汇总信息
	 * @date 2015-12-3
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByDrugsMonth(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select adm.*,bgi.qualityspec_name drug_name,bgi.form_name,bgi.spec_name, ")
		.append(" bgi.factor,bgi.unit_name,bgi.material_name,bgi.prod_compname,bgi.prod_compcode ")
		.append(" from ana_druginfo_mon adm left join base_goods_item bgi on bgi.drug_code =adm.drug_code where 1=1  ");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and adm.is_basic=:isBasic ");
		}
		sql.append(" ORDER BY adm.date desc ");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaTotalByTimeMonth() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select admt.ana_id,admt.is_basic,admt.total_amount,admt.del_amount,admt.ret_amount,")
		.append("admt.date from ana_druginfo_mon_total admt where :date <= admt.date")
		.append(" ORDER BY admt.date");
		
		map.put("date", ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -7)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品采购季度汇总信息
	 * @date 2015-12-3
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByDrugsSea(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ads.*,bgi.qualityspec_name drug_name,bgi.form_name,bgi.spec_name, ")
		.append(" bgi.factor,bgi.unit_name,bgi.material_name,bgi.prod_compname,bgi.prod_compcode ")
		.append(" from ana_druginfo_season ads left join base_goods_item bgi on bgi.drug_code =ads.drug_code where 1=1  ");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			map.put("starttime", map.get("starttime").replace("年", "0").replace("季度", ""));
			sql.append(" AND date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			map.put("endtime", map.get("endtime").replace("年", "0").replace("季度", ""));
			sql.append(" AND date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and ads.is_basic=:isBasic ");
		}
		sql.append(" ORDER BY ads.date  desc");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaTotalByTimeQuarter() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select adts.ana_id,adts.is_basic,adts.total_amount,adts.del_amount,adts.ret_amount,")
		.append("adts.date from ana_druginfo_total_sea adts where :date <= adts.date")
		.append(" ORDER BY adts.date");
		
		map.put("date", ParseDate.getSea(ParseDate.addMonth(new Date(), -21)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品采购年汇总信息
	 * @date 2015-12-3
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByDrugsYear(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ady.*,bgi.qualityspec_name drug_name,bgi.form_name,bgi.spec_name, ")
		.append(" bgi.factor,bgi.unit_name,bgi.material_name,bgi.prod_compname,bgi.prod_compcode ")
		.append(" from ana_druginfo_year ady left join base_goods_item bgi on bgi.drug_code =ady.drug_code where 1=1  ");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND ady.date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND ady.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and ady.is_basic=:isBasic ");
		}
		sql.append(" ORDER BY ady.date  desc");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaTotalByTimeYear() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select adty.ana_id,adty.is_basic,adty.total_amount,adty.del_amount,adty.ret_amount,")
		.append("adty.date from ana_druginfo_total_year adty where :date <= adty.date")
		.append(" ORDER BY adty.date ");
		
		map.put("date", ParseDate.parseShortYearFormat(ParseDate.addYear(new Date(), -7)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按医院统计(年)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalLastYear(){
		StringBuffer sql = new StringBuffer()
		.append("select hosp_code,hosp_name,base_amount,nonbase_amount,total_amount/10000 total_amount,base_ratio,del_amount/10000 del_amount,ret_amount/10000 ret_amount,")
		.append("del_ratio,ret_ratio,date from ana_hospital_year where date = :lastYear order by total_amount desc limit 10");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("lastYear", Calendar.getInstance().get(Calendar.YEAR)-1);
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按医院统计(日)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalYesterday(){
		StringBuffer sql = new StringBuffer()
		.append("select hosp_code,hosp_name,base_amount,nonbase_amount,total_amount/10000 total_amount,base_ratio,del_amount/10000 del_amount,ret_amount/10000 ret_amount,")
		.append("del_ratio,ret_ratio,date from ana_hospital where date = :yesterday order by total_amount desc limit 10");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("yesterday", DateUtil.date(new Timestamp(System.currentTimeMillis()-1000 * 60 * 60 * 24)).replaceAll("-", ""));
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按医院统计(月)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalLastMonth(){
		StringBuffer sql = new StringBuffer()
		.append("select hosp_code,hosp_name,base_amount,nonbase_amount,total_amount/10000 total_amount,base_ratio,del_amount/10000 del_amount,ret_amount/10000 ret_amount,")
		.append("del_ratio,ret_ratio,date from ana_hospital_mon where date = :lastMonth order by total_amount desc limit 10");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("lastMonth", ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1)));
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按医院统计(季)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalLastQuarter(){
		StringBuffer sql = new StringBuffer()
		.append("select hosp_code,hosp_name,base_amount,nonbase_amount,total_amount/10000 total_amount,base_ratio,del_amount/10000 del_amount,ret_amount/10000 ret_amount,")
		.append("del_ratio,ret_ratio,date from ana_hospital_sea where date = :lastQuarter order by total_amount desc limit 10");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("lastQuarter", ParseDate.getSea(ParseDate.addMonth(new Date(), -3)));
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按企业统计(日)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getAnaByComp(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name,ah.date, ")
		.append(" ah.total_amount,ah.base_amount,ah.nonbase_amount,ah.ret_amount, ")
		.append(" ah.base_ratio, ")
		.append(" ah.ret_ratio ")
		.append("  from ana_compinfo ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			map.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startDate"))) {
			map.put("startDate", map.get("startDate").replaceAll("-", ""));
			sql.append(" and ah.date >= :startDate ");
		}
		if (StringUtils.isNotBlank(map.get("endDate"))) {
			map.put("endDate", map.get("endDate").replaceAll("-", ""));
			sql.append(" and ah.date <= :endDate ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), map, page);
	}



/**
	 * @category 按企业统计(年)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getYearAnaByComp(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name,ah.date, ")
		.append(" ah.total_amount,ah.base_amount,ah.nonbase_amount,ah.ret_amount, ")
		.append(" ah.base_ratio, ")
		.append(" ah.ret_ratio ")
		.append("  from ana_compinfo_year ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			map.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startYear"))) {
			sql.append(" and ah.date >= :startYear ");
		}
		if (StringUtils.isNotBlank(map.get("endYear"))) {
			sql.append(" and ah.date <= :endYear ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), map, page);
	}
	
	
	/**
	 * @category 按企业统计(季度)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getSeaAnaByComp(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name,ah.date, ")
		.append(" ah.total_amount,ah.base_amount,ah.nonbase_amount,ah.ret_amount, ")
		.append(" ah.base_ratio, ")
		.append(" ah.ret_ratio ")
		.append("  from ana_compinfo_sea ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			map.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startSea"))) {
			map.put("startSea", map.get("startSea").replaceAll("年第", "0").replaceAll("季度", ""));
			sql.append(" and ah.date >= :startSea ");
		}
		if (StringUtils.isNotBlank(map.get("endSea"))) {
			map.put("endSea", map.get("endSea").replaceAll("年第", "0").replaceAll("季度", ""));
			sql.append(" and ah.date <= :endSea ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 按企业统计(月)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getMonthAnaByComp(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name,ah.date, ")
		.append(" ah.total_amount,ah.base_amount,ah.nonbase_amount,ah.ret_amount, ")
		.append(" ah.base_ratio, ")
		.append(" ah.ret_ratio ")
		.append("  from ana_compinfo_mon ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			map.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startMonth"))) {
			map.put("startMonth", map.get("startMonth").replaceAll("-", ""));
			sql.append(" and ah.date >= :startMonth ");
		}
		if (StringUtils.isNotBlank(map.get("endMonth"))) {
			map.put("endMonth", map.get("endMonth").replaceAll("-", ""));
			sql.append(" and ah.date <= :endMonth ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 按企业统计(年)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalByCompLastYear(){
		StringBuffer sql = new StringBuffer()
		.append("select del_comp_code,del_comp_name,base_amount,nonbase_amount,total_amount/10000 total_amount,base_ratio,del_amount/10000 del_amount,ret_amount/10000 ret_amount,")
		.append("del_ratio,ret_ratio,date from ana_compinfo_year where date = :lastYear order by total_amount desc limit 10");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("lastYear", Calendar.getInstance().get(Calendar.YEAR)-1);
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按企业统计(日)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalByCompYesterday(){
		StringBuffer sql = new StringBuffer()
		.append("select del_comp_code,del_comp_name,base_amount,nonbase_amount,total_amount/10000 total_amount,base_ratio,del_amount/10000 del_amount,ret_amount/10000 ret_amount,")
		.append("del_ratio,ret_ratio,date from ana_compinfo where date = :yesterday order by total_amount desc limit 10");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("yesterday", DateUtil.date(new Timestamp(System.currentTimeMillis()-1000 * 60 * 60 * 24)).replaceAll("-", ""));
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按企业统计(月)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalByCompLastMonth(){
		StringBuffer sql = new StringBuffer()
		.append("select del_comp_code,del_comp_name,base_amount,nonbase_amount,total_amount/10000 total_amount,base_ratio,del_amount/10000 del_amount,ret_amount/10000 ret_amount,")
		.append("del_ratio,ret_ratio,date from ana_compinfo_mon where date = :lastMonth order by total_amount desc limit 10");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("lastMonth", ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1)));
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按企业统计(季)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalByCompLastQuarter(){
		StringBuffer sql = new StringBuffer()
		.append("select del_comp_code,del_comp_name,base_amount,nonbase_amount,total_amount/10000 total_amount,base_ratio,del_amount/10000 del_amount,ret_amount/10000 ret_amount,")
		.append("del_ratio,ret_ratio,date from ana_compinfo_sea where date = :lastQuarter order by total_amount desc limit 10");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("lastQuarter", ParseDate.getSea(ParseDate.addMonth(new Date(), -3)));
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 首页的柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getHomeChartData(){
		StringBuffer sql = new StringBuffer()
		.append("select is_basic,total_amount/10000 total_amount,del_amount/10000 del_amount,ret_amount/10000 ret_amount,")
		.append("date from ana_druginfo_mon_total where date < :lastMonth order by date limit 6");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("lastMonth", ParseDate.parseDateToYm(new Date()));
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品采购总量日汇总列表信息
	 * @date 2015-12-3
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@Override
	public Pagination getAnaListByTime(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append("select adt.ana_id,adt.is_basic,adt.total_amount,adt.del_amount,adt.ret_amount,")
		.append("adt.date,adt.ret_ratio,adt.del_ratio from ana_druginfo_total adt  where 1=1  ");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND adt.date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND adt.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and adt.is_basic=:isBasic ");
		}
		sql.append(" ORDER BY adt.date desc ");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 获取药品采购总量月汇总列表信息
	 * @date 2015-12-3
	 * @author lil
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaListByTimeMonthCS(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append("select admt.ana_id,admt.is_basic,admt.total_amount,admt.del_amount,admt.ret_amount,")
		.append("admt.date,admt.ret_ratio,admt.del_ratio from ana_druginfo_mon_total admt where 1=1");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND admt.date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND admt.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and admt.is_basic=:isBasic ");
		}
		sql.append(" ORDER BY admt.date desc ");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 获取药品采购总量季度汇总列表信息
	 * @date 2015-12-3
	 * @author lil
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaListByTimeQuarterCS(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append("select adts.ana_id,adts.is_basic,adts.total_amount,adts.del_amount,adts.ret_amount,")
		.append("adts.date,adts.ret_ratio,adts.del_ratio from ana_druginfo_total_sea adts where 1=1");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			map.put("starttime", map.get("starttime").replace("年", "0").replace("季度", ""));
			sql.append(" AND adts.date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			map.put("endtime", map.get("endtime").replace("年", "0").replace("季度", ""));
			sql.append(" AND adts.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and adts.is_basic=:isBasic ");
		}
		sql.append(" ORDER BY adts.date desc ");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 获取药品采购总量年汇总列表信息
	 * @date 2015-12-3
	 * @author lil
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaListByTimeYearCS(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append("select adty.ana_id,adty.is_basic,adty.total_amount,adty.del_amount,adty.ret_amount,")
		.append("adty.date,adty.ret_ratio,adty.del_ratio from ana_druginfo_total_year adty where 1=1");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND adty.date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND adty.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and adty.is_basic=:isBasic ");
		}
		sql.append(" ORDER BY adty.date desc ");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 获取地区每日销售量前十的地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByArea() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.area_name,t.total_amount,t.base_amount,t.nonbase_amount,t.del_amount,t.ret_amount")
		.append(" from ana_area t where t.date = :date  order by t.total_amount desc limit 10");
		
		map.put("date", ParseDate.parseDateToYmd(ParseDate.addDate(new Date(), -1)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取地区销售量前十的上一月地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByAreaWithMon() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.area_name,t.total_amount,t.base_amount,t.nonbase_amount,t.del_amount,t.ret_amount")
		.append(" from ana_area_mon t where t.date = :date  order by t.total_amount desc limit 10");
		
		map.put("date", ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取地区销售量前十的上一季度地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByAreaWithSea() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.area_name,t.total_amount,t.base_amount,t.nonbase_amount,t.del_amount,t.ret_amount")
		.append(" from ana_area_sea t where t.date = :date  order by t.total_amount desc limit 10");
		
		map.put("date", ParseDate.getSea(ParseDate.addMonth(new Date(), -3)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取地区销售量前十的上一年地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByAreaWithYear() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.area_name,t.total_amount,t.base_amount,t.nonbase_amount,t.del_amount,t.ret_amount")
		.append(" from ana_area_year t where t.date = :date  order by t.total_amount desc limit 10");
		
		map.put("date", ParseDate.parseShortYearFormat(ParseDate.addYear(new Date(), -1)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	
	/**
	 * @category 获取药品每日销售量前十的地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByDrugs() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.total_amount,t.del_amount,t.ret_amount,bgi.qualityspec_name drug_name ")
		.append("from ana_druginfo t left join base_goods_item bgi on bgi.drug_code =t.drug_code ")
		.append("where t.date = :date order by t.total_amount DESC limit 10");
		
		map.put("date", ParseDate.parseDateToYmd(ParseDate.addDate(new Date(), -1)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品销售量前十的上一月地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByDrugsMon() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.total_amount,t.del_amount,t.ret_amount,bgi.qualityspec_name drug_name ")
		.append("from ana_druginfo_mon t left join base_goods_item bgi on bgi.drug_code =t.drug_code ")
		.append("where t.date = :date order by t.total_amount DESC limit 10");
		
		map.put("date", ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品销售量前十的上一季度地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByDrugsSea() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.total_amount,t.del_amount,t.ret_amount,bgi.qualityspec_name drug_name ")
		.append("from ana_druginfo_season t left join base_goods_item bgi on bgi.drug_code =t.drug_code ")
		.append("where t.date = :date order by t.total_amount DESC limit 10");
		
		map.put("date", ParseDate.getSea(ParseDate.addMonth(new Date(), -3)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品销售量前十的上一年地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByDrugsYear() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.total_amount,t.del_amount,t.ret_amount,bgi.qualityspec_name drug_name ")
		.append("from ana_druginfo_year t left join base_goods_item bgi on bgi.drug_code =t.drug_code ")
		.append("where t.date = :date order by t.total_amount DESC limit 10");
		
		map.put("date", ParseDate.parseShortYearFormat(ParseDate.addYear(new Date(), -1)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
}
